home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
ACORNUSERS
/
CBSA
/
UTILS
/
SIZEVAR
/
SizeVarMsg
< prev
next >
Wrap
Text File
|
1998-01-15
|
3KB
|
74 lines
© Copyright Nicholas Clark 1998
SizeVar is a short utility to create OS code variables which reflect the total
size of and amount of free memory in various parts of system. By using
appropriate command line flags (see below) any of the following variables can be
created:
System$Size
Module$Size Module$Free
Screen$Size Screen$Free
Sprite$Size Sprite$Free
Font$Size Font$Free
RAMFS$Size RAMFS$Free
Reading a size variable (eg "*echo <Screen$Size>") gives the current memory
assigned to that part of the system (in bytes - see below for kilobytes).
Assigning to a size variable will attempt to change the particular system
setting (or return an error if an error occurs). The system rounds the value you
give up to the next multiple of the memory page size (on a RiscPC this means
that it will round up to the next 4K) so you may not set the exact size you
actually specify.
Reading a free variable gives the current free memory in that part of the
system, and assigning to it tries to increase (or decrease) the free memory to
as close as possible to the size you specify.
In both cases after assigning to a variable it is wise to read it again, to see
what memory change actually happened.
Note that Module$Free is a little special - Module$Free returns the size of the
largest free block in the RMA, and assigning to it assumes that this block is at
the end of the RMA when it calculates how much to change the RMA size by.
To reliably ensure that you have room for a given module, set Module$Size to
<Module$Size> + size_of_your_module.
The 11 variables come as packaged a single utility that creates any combination
given the appropriate command line parameters. One 2K utility uses a lot less
disc space than 11 1K utilities, one for each variable.
If you wish to generate all 11 variables use the -All switch - ie
*SizeVar -All
To generate all 6 Size variables use the -Size switch. Similarly, to generate
the 5 Free variables use the -Free switch.
To specify variables to generate singularly precede the name with '-' and
replace '$' with '_'. For example, to generate Font$Size and Module$Free, call
*SizeVar -Font_Size -Module_Free
Size variables can also be specified by the number of their dynamic area - as
the RAMFS is dynamic area 5, to generate RAMFS$Size you can also call
*SizeVar -5
(this isn't very user friendly but as the generation code in the utility
actually parses the OS_ReadArgs string to find the variable names and
corresponding dynamic area, it's easier to leave it in and document it!
Confused - see the source code - you will be!)
If you want the variables to work in hexadecimal rather than decimal, alter the
flag on 8th line of the BASIC source code and re-assemble.
If you want the variables to work in kilobytes rather than bytes (beware of the
rounding effects) see the flag the 10th line of the BASIC source code and
re-assemble.
Hopefully the source serves as an example of how to write a transient utility,
and how to write a code variable.
I would prefer it it if you distribute the source with the executable
Feel free to use this in anything free. Feel free to modify/improve it.
Feel obliged to send me any bug fixes at <nick@unfortu.net>